(function($){
    $(document).ready(function () {
        /*模板引擎设置*/
        _.templateSettings = {
            interpolate: /\{\{(.+?)\}\}/g
        };

        var InvoiceItemModel=Backbone.Model.extend({});

        var InvoiceItemCollection=Backbone.Collection.extend({
            model:InvoiceItemModel
        });


        var InvoiceItemView=Backbone.View.extend({
            el:"#res",
            render:function(){
                var html="<div>"+this.model.get('description')+"</div>";
                html+="<div>"+this.model.get("price")+"</div>";
                html+="<div>"+this.model.get("quantity")+"</div>";
                $(this.el).html(html);
            },

            initialize:function(){
                this.listenTo(this.model,'change',this.render,this);
            }
        });

        var invoiceItemModel=new InvoiceItemModel({
            description:"Farmer Figure",
            price:8,
            quantity:2
        });

        var invoiceItemView=new InvoiceItemView({
            model:invoiceItemModel
        });

        invoiceItemView.render();

        invoiceItemModel.set("quantity",12);

        window.invoiceItemModel=invoiceItemModel;

    });
})(jQuery);